<template>
	<view class="card padding-xs flex align-center">
		<view class="flex-sub text-center" v-if="value!={}">
			<view class="solid-bottom text-xsl">
				<text class="cuIcon-info text-orange" v-if="value.isCancel===1"></text>
				<text class="cuIcon-roundclose text-red" v-else-if="value.mainStatus===0 || value.applyStatus===0"></text>
				<text class="cuIcon-info text-orange" v-else-if="value.mainStatus===1 || value.applyStatus===1"></text>
				<text class="cuIcon-roundcheck text-green" v-else-if="value.mainStatus===2  || value.applyStatus===2"></text>
			</view>
			<view v-if="value.isCancel===1" class="padding text-xl text-black">已撤销</view>
			<view v-else class="padding text-xl text-black">审核<text v-if="value.mainStatus===0 || value.applyStatus===0">不通过</text><text v-else-if="value.mainStatus===1 || value.applyStatus===1">中</text><text
				 v-else-if="value.applyStatus===2 && value.mainStatus===2">通过</text></view>
			<view class="padding text-black" v-if=" value.mainStatus===0 || value.applyStatus===0">拒绝原因：<text class="text-red">{{value.banReason}}</text></view>
			<!-- <view class="text-left padding-bottom-xs">申请类型：<text v-if="!value.applyType">人员申请</text><text v-else>车辆申请</text></view> -->
			<!-- 12.24新增 top-->
			<view class="info text-left padding-bottom-xs"><text class="label">校内接待部门：</text>{{value.departName}}</view>
			<view class="info text-left padding-bottom-xs"> <text class="label">校内联系人：</text> {{value.concatName}}</view>
			<view class="info text-left padding-bottom-xs"><text class="label">校内联系人电话：</text>{{value.concatPhone}}</view>
			<!-- 12.24新增 bottom -->
			<view class="info text-left padding-bottom-xs" v-if="value.userDays"><text class="label">入校日期：</text>{{value.userDays}}</view>
			<view class="info text-left padding-bottom-xs" v-if="value.campus"><text class="label">入校校区：</text>{{value.campus}}</view>
			<view v-if="value.userCarList" v-for="(item,index) in value.userCarList" :key="index">
				<view class="info text-left padding-bottom-xs"><text class="label">来访人姓名：</text>{{item.userName}} <text  v-if="value.applyStatus===2 && value.mainStatus===2 && (value.createTime && value.createTime > '2023-10-10 00:00:00')" style="margin-left: 10rpx;text-decoration: underline;color: #004d95;" @click="toQrcode(item.qrCode)"> 查看进校二维码</text></view>
				<view class="info text-left padding-bottom-xs"><text class="label">证件号码：</text>{{item.cardNo}}</view>
				<view class="info text-left padding-bottom-xs" v-if="item.carNumber"><text class="label">车牌号码：</text>{{item.carNumber}}</view>
			</view>
			<view v-if="value.checkUserName" class="info text-left padding-bottom-xs"><text class="label">审核人员:</text> {{value.checkUserName}}</view>
			<view v-if="value.progress" class="info text-left padding-bottom-xs"><text class="label">审核进度：</text>{{value.progress}}</view>
			<view class="btns" v-if="(value.isCancel!==1 && canWithdraw(value)) || ((value.mainStatus!==0 && value.applyStatus!==0) && (value.mainStatus===1 || value.applyStatus===1))">
				<template>
					<view class="btn1" v-if="value.isCancel!==1 && canWithdraw(value)" @click="withdraw(value)">撤销</view>
					<view class="btn2" v-if="value.isCancel!==1 && (value.mainStatus!==0 && value.applyStatus!==0) && (value.mainStatus===1 || value.applyStatus===1)" @click="toEdit(value)">编辑</view>
				</template>
			</view>
			<view v-else style="height: 30rpx;"></view>
		</view>
	</view>
</template>

<script>
	import baseUrl from '../../api/api.js'
	import {dateFormat} from '@/common/utils.js'
	
	export default {
		props: {
			value: Object,
		},
		methods:{
			canWithdraw(value) {
				console.log('value', value.endDate, dateFormat(new Date(), 'yyyy-MM-dd'),value.endDate < dateFormat(new Date(), 'yyyy-MM-dd'));
				return value.endDate > dateFormat(new Date(), 'yyyy-MM-dd')
			},
			toQrcode(qrCode) {
				uni.navigateTo({
					url: '/pages/qrcode/qrcode?see=1&canBack=1&' + qrCode
				})
			},
			toEdit(value) {
				this.$emit('edit', value)
			},
			withdraw(value) {
				uni.showModal({
					title: '提示',
					content: '申请撤销后不可恢复，请确定是否撤销',
					success: (res) => {
						if(res.confirm) {
							uni.request({
								url: baseUrl.baseUrl + "zkd/apply/remove",
								data: {
									id: value.id
								},
								method: 'POST',
								success: () => {
									this.$emit('refresh')
								}
							})
						}
					}
				})
			}
		}
	}
	
</script>

<style lang="scss">
	.card {
		box-shadow: 0 0 10rpx 4rpx rgba(0, 0, 0, 0.1);
		background-color: #ffffff;
		transition: transform 0.2s;
		margin-bottom: 20rpx;
		padding: 30rpx 30rpx 0 30rpx;
		
		.info {
			display: flex;
	
		}
		.label {
			width: 230rpx;
			flex-shrink: 0;
			text-align: justify;
		}
	}
	.btns {
		display: flex;
		align-items: center;
		margin-top: 10rpx;
		height: 88rpx;
		line-height: 88rpx;
		border-top: 1rpx solid #eee;
		.btn1,.btn2 {
			flex: 1;
		}
		.btn1 {
			border-right: 1rpx solid #eee;
			color: red;
		}
		.btn2 {
			color: #004d95;
		}
	}
</style>